Parallelism config + TP + HSDP + BYODM (Bring Your Own Device Mesh)#3682
Conversation
d9aec5c to
a402faf
Compare
| def _prepare_fsdp2(self, *args): | ||
| # First pass: prepare everything except schedulers (and model, which is prepared separately below) | ||
| result = [ |
There was a problem hiding this comment.
nice ! We will be able to clean up a bit trainer code after that
| def build_device_mesh(self, device_type: str): | ||
| mesh = self.get_mesh() | ||
| if not len(list(mesh)): | ||
| return |
There was a problem hiding this comment.
yeah we should probably raise an error but tbh we don't really need to deal with this case
|
|
||
| ### FSDP2 + ND Parallelism | ||
|
|
||
| With `AccelerateDistributedConfig`, you can use 🤗 accelerate to train with n-dimensional parallelism. Script `nd_parallel.py` showcases just how you can do it. We enable you to configure 3 different parallel dimensions: |
There was a problem hiding this comment.
You mean ParallelConfig no ?
| With `AccelerateDistributedConfig`, you can use 🤗 accelerate to train with n-dimensional parallelism. Script `nd_parallel.py` showcases just how you can do it. We enable you to configure 3 different parallel dimensions: | |
| With `ParallelConfig`, you can use 🤗 accelerate to train with n-dimensional parallelism. Script `nd_parallel.py` showcases just how you can do it. We enable you to configure 3 different parallel dimensions: |
There was a problem hiding this comment.
I think we have both because of the duplicate config upstream in transformers - but it would be good to clarify which to use.
There was a problem hiding this comment.
It will be better to use the one from accelerate
| <Tip> | ||
| Only use TP intra-node - therefore max TP size you should need is 8, you can also lower this as FSDP (`--dp-shard-size`) can be faster on smaller models with | ||
| shorter sequence lengths. If you still cannot fit into memory, utilize `--dp-shard-size` as much as you can. Then to scale up to utilize all your GPUs, fill the rest | ||
| with `--dp-replicate-size`. This is only a general guideline, you can (and should) experiment with different parallelism configurations to find the best one for your model and hardware. You can learn more about the general strategies for parallelism in our [blog](TODO) or if you wanna dive deep, read the [Ultra-Scale Playbook](https://huggingface.co/spaces/nanotron/ultrascale-playbook). |
There was a problem hiding this comment.
Well the blog isn't ready, so we kind of need to keep the todo there haha (we'll finish before release)
| def parallelism_config(self) -> ParallelismConfig | None: | ||
| return self.state.parallelism_config |
There was a problem hiding this comment.
| syntax only works with py3.10 but we still need to support py3.9
There was a problem hiding this comment.
we will drop py3.9 in october btw !
What does this PR do?
Building on #3651
Dependencies:
ParallelismConfigin HFTrainerFixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
cc @S1ro1
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.